package homework;

public class MyNumber extends Thread{
    private static Object obj = new Object();

    public MyNumber() {
    }

    public MyNumber(String name) {
        super(name);
    }

    @Override
    public void run() {
        synchronized (obj) {
            for (int i = 1; i <= 100; i++) {
                if(i%2==1){
                    System.out.println(getName()+"奇数为"+i);
                    i++;
                }else {
                    break;
                }
            }
        }
    }
}
